Skip to content

[AST] Remove an unnecessary cast (NFC) #149338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

getFinallyStmt() already returns ObjCAtFinallyStmt *.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 17, 2025

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

Changes

getFinallyStmt() already returns ObjCAtFinallyStmt *.


Full diff: https://github.com/llvm/llvm-project/pull/149338.diff

1 Files Affected:

  • (modified) clang/lib/AST/StmtPrinter.cpp (+1-1)
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index be02bdde38a3d..5d4c8370dfb5f 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -610,7 +610,7 @@ void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
     }
   }
 
-  if (auto *FS = static_cast<ObjCAtFinallyStmt *>(Node->getFinallyStmt())) {
+  if (auto *FS = Node->getFinallyStmt()) {
     Indent() << "@finally";
     if (auto *CS = dyn_cast<CompoundStmt>(FS->getFinallyBody())) {
       PrintRawCompoundStmt(CS);

getFinallyStmt() already returns ObjCAtFinallyStmt *.
@kazutakahirata kazutakahirata force-pushed the cleanup_20250717_cast_clang_AST branch from a5c8742 to 3ad8b6f Compare July 17, 2025 21:35
@kazutakahirata kazutakahirata merged commit f48e2bb into llvm:main Jul 17, 2025
9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250717_cast_clang_AST branch July 17, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants